<?php
class Codingfrenzyinstall extends CI_Controller{
	
	
	function index(){
		
		$this->load->model('install_model');
		if($this->install_model->is_installed() == true){
			redirect('login');
		}else{
		//	$sess = array(
		//	'install' => true,
		//);
		//$this->session->set_userdata($sess);
			$this->load->view('install_view');
			
		}
	}
	
	
	function is_installing(){
		$install = $this->session->userdata('install');
		if(!isset($install) || $install != true){
			redirect('codingfrenzyinstall');
		}
	}
	
	function install(){
		//$this->is_installing();
		$this->load->model('install_model');
		$data = $this->install_model->create_table($this->install_model->get_table_info());
		
		if($data == true){
			$this->load->view('create_admin_view');
		}
	}
	
	function create_admin(){
		$data = array(
			'username' => $this->input->post('username'),
			'password' => md5($this->input->post('password')),
			'active' => 1,
		);
		
		$this->load->model('install_model');
		if($this->install_model->create_admin($data) == true){
		//	$this->session->sess_destroy();
			redirect('login');
		}
		
	}
	
	
}